$(function(){
	
	var supplier = {
		url : site.url + 'supplier/',
		getContact : function(){

		},
		del : function($o, single){
			url = supplier.url + 'del';
			name = 'supplier_id';
			if ('single' == single) {
				$obj = $o.parents('.supplier');
				$tobj = $obj.find('input[type=checkbox]');
			}
			else {
				$tobj = $('.supplier input:checked');
				$obj = $tobj.parents('.supplier');
			}
			ajax.dataList.del(url, $tobj, name, function(){
				$obj.removeClass('del-flg-0').addClass('del-flg-1')
				.find('.del').removeClass('del').addClass('recover')
				.unbind('click').bind('click', function(){supplier.recover($(this),'single')});
			});
		},
		recover : function($o, single){
			url = supplier.url + 'recover';
			name = 'supplier_id';
			if ('single' == single) {
				$obj = $o.parents('.supplier');
				$tobj = $obj.find('input[type=checkbox]');
			}
			else {
				$tobj = $('.supplier input:checked');
				$obj = $tobj.parents('.supplier');
			}
			ajax.dataList.recover(url, $tobj, name, function(){
				$obj.removeClass('del-flg-1').addClass('del-flg-0')
				.find('.recover').removeClass('recover').addClass('del')
				.unbind('click').bind('click', function(){supplier.del($(this),'single')});
			});
		}
	}

	$('.supplier .btn .del').bind('click', function(){supplier.del($(this),'single')});
	$('#group #check-del').bind('click', function(){supplier.del($(this))});
	$('.supplier .btn .recover').bind('click', function(){supplier.recover($(this),'single')});
	$('#group #check-recover').bind('click', function(){supplier.recover($(this))});

})